import { parserHTML } from "./parser";
import { generate } from "./generate";
export function compileToFunction(template) {
  const root = parserHTML(template);
  console.log("root", root);
  // html => ast => render函数 => vdom   增加额外的属性 =》 生成真实dom

  //生成代码
  let code = generate(root);
  console.log("code", code);

  // let render = new Function(code)
  let render = new Function(`with(this){return ${code}}`);
  return render;
}
